﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using NLog;
using System.Windows.Forms;

namespace Tab2Sql
{
 

    partial class AboutBox1 : Form
    {
		private static Logger logger = LogManager.GetCurrentClassLogger ();
        string AssemblyVersion = "";
        string AssemblyTitle="";
        protected string AssemblyCompany="";
        protected string AssemblyProduct;
        protected string AssemblyCopyright;
        protected string AssemblyDescription;

        public AboutBox1 ()
        {
            InitializeComponent ();
            Assemblage asm = new Assemblage ();
            this.AssemblyTitle = asm.AssemblyTitle;
            this.AssemblyVersion = asm.AssemblyVersion;
            this.AssemblyProduct = asm.AssemblyProduct;
            this.AssemblyCompany = asm.AssemblyCompany;
            var bd = Properties.Settings.Default.Build_Date.ToString ();

        	DateTime resultBD;
            var dx = DateTime.Now;
            string specialSuffix = "";
            logger.Trace ("BuildDate crap:{0}-{1}", bd, dx);
            if (DateTime.TryParse (bd, out resultBD) == true)
            {
                if (resultBD.Year < 2000)
                {
                    resultBD = dx.ToUniversalTime ();
                }
                bd = resultBD.ToUniversalTime ().ToString ();

				//specialSuffix += string.Format ("\n"+Properties.Settings.Default.Build_Date.ToString ());

			}
        	if (DateTime.TryParse (bd, out resultBD) == false)
			{
        		
        		bd = dx.ToUniversalTime ().ToString ();
        		specialSuffix += string.Format ("tryparse fail:{0}-{1}-{2}", dx.Year, dx.Month, dx.Day);
    
				
        	}
        	
        	string aDescription = asm.AssemblyDescription.Replace ("<<LASTBUILD>>", bd);
        	
            aDescription = aDescription + Environment.NewLine + Environment.NewLine + asm.AssemblyVersion + specialSuffix;
			this.AssemblyDescription = aDescription + specialSuffix;
            this.AssemblyCopyright = asm.AssemblyCopyright;

            this.Text = String.Format("About {0} ", asm.AssemblyTitle);
            this.labelProductName.Text = asm.AssemblyProduct;
            this.labelVersion.Text = String.Format("Version {0} ", asm.AssemblyVersion);

            this.labelCompanyName.Text = asm.AssemblyCompany;
            this.textBoxDescription.Text = aDescription;
          
        }

 

        private void okButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
